---
id: 655a452d40556e5c25e4aac8
title: Passo 26
challengeType: 20
dashedName: step-26
---

# --description--

The next step is to work on the deletion of nodes.

Within the `BinarySearchTree` class, define a `delete` method. It takes two parameters: `self` and `key`.

`key` is the value that the user wants to delete from the binary search tree.

# --hints--

You should define a `delete` method with two parameters: `self` and `key`. Remember to use `pass`.

```js
({ test: () => assert.match(code, /def\s+delete\(\s*self\s*,\s*key\s*\)/) });
```

# --seed--

## --seed-contents--

```py
class TreeNode:
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None

class BinarySearchTree:
    def __init__(self):
        self.root = None

    def insert(self,key):
        self.root = self._insert(self.root, key)

    def _insert(self, node, key):
        if node is None:
            return TreeNode(key)
        if key < node.key:
            node.left = self._insert(node.left, key)
        elif key > node.key:
            node.right = self._insert(node.right, key)
        return node

    def search(self, key):
        return self._search(self.root, key)

    def _search(self, node, key):
        if node is None or node.key == key:
            return node
        if key < node.key:
            return self._search(node.left, key)
        return self._search(node.right, key)
--fcc-editable-region--

--fcc-editable-region--
```
